<template>
  <h2>readonly和shallowReadonly</h2>
  <h3>state2:{{state2}}</h3>
  <hr>
  <button @click="update">更新数据</button>
</template>
<script lang="ts">
import { defineComponent, reactive, readonly, shallowReadonly } from 'vue'
export default defineComponent({
  name: 'App',
  setup () {
    const state = reactive({
      name: '佐助',
      age: 20,
      car: {
        name: '奔驰',
        color: 'yellow'
      }
    })
    // const state2 = readonly(state)
    const state2 = shallowReadonly(state)
    const update = () => {
      console.log('ceshi')
      // state2.name += '==='
      state2.car.name += '=='
    }
    return {
      state,
      state2,
      update
    }
  }
})
</script>
